package com.csc.consumer;



import java.util.List;

/**
 * @description:
 * @author: ChenShuCheng
 * @create: 2021-07-04 21:08
 **/
public class Consume {

    public String doConsume(String key){
        //todo
//        return Broker.readMsg(key);
    }

    public List<String> doConsumeFromCopies(String key){
//        return Broker.readMsgFromList(key);
    }





    public static void start() {
        Consume consumer = new Consume();
        String topic = "天问一号";
        while (true ){
            String s = consumer.doConsume(topic);
            if (s != null) {
                System.out.println(Thread.currentThread().getName()+s);
            }
        }
    }

    public static void start(int index) {
        Consume consumer = new Consume();
        String topic = "天问一号";
        while (true){
            List<String> msgList = consumer.doConsumeFromCopies(topic);
            if (msgList != null && msgList.size() != 0){
                for (String msg : msgList) {
                    if (msg != null) {
                        System.out.println(Thread.currentThread().getName()+msg);
                    }
                }
            }
        }

    }
}
